﻿using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;

//[InitializeOnLoad]
public class SaveInfo : Singleton<SaveInfo> 
{
	public enum SaveDataType
	{
		STRING = 0,
		INT,
		FLOAT
	}

	[System.Serializable]
	public class AttributeNameValue
	{
		public string m_AttributeName;
		public SaveDataType m_AttributeType = SaveDataType.STRING;

		[HideInInspector]
		public SaveGameManager.SaveData m_SaveData = null;
	}

	public AttributeNameValue[] m_AllSaveInfo;

	protected override void Awake()
	{
		base.Awake();
		FillEmpties();
		SaveGameManager.Instance.Initialize();
	}

	private void FillEmpties()
	{		
		for(int i = 0; i < m_AllSaveInfo.Length; i++)
		{
			if(m_AllSaveInfo[i].m_SaveData.m_Value == null)
			{
				if(m_AllSaveInfo[i].m_AttributeType == SaveDataType.STRING)
				{
					m_AllSaveInfo[i].m_SaveData.m_Value = "";
				}
				else if(m_AllSaveInfo[i].m_AttributeType == SaveDataType.INT)
				{
					m_AllSaveInfo[i].m_SaveData.m_Value = 0;
				}
				else if(m_AllSaveInfo[i].m_AttributeType == SaveDataType.FLOAT)
				{
					m_AllSaveInfo[i].m_SaveData.m_Value = 0f;
				}
			}
		}
	}
	
	public SaveDataID.AttributeID GetAttributeID(string i_ID)
	{
		//for( int i = 0; i < m_AllSaveInfo.Length; i++)
		//{
		//	if(i_ID == 
		//}

		Array enumValue = Enum.GetValues(typeof(SaveDataID.AttributeID));

		for(int i = 0; i < enumValue.Length; i++)
		{
			if(i_ID == enumValue.GetValue(i).ToString())
			{
				return (SaveDataID.AttributeID)enumValue.GetValue(i);
			}
		}

		return SaveDataID.AttributeID.NONE;
	}
}
